Cnbi.model.Capital_Chain = function(params){
	
	Cnbi.model.BaseSliderAndProgress.call(this,params);
	var scope = this,
		flag=false,
		datas={},
		i ,
		domArray = params["domArray"];
	this.initPage = function(){		
		
		if(!scope.flag){
	      	CnbiSoft.setCurrentRenderer("JavaScript");
	  	}
	  	this.initData();
	  	this.setSliderValue(params.slider_array,scope.datas,params.updateInput);
	  	this.setProgressValue(params.progress_array,scope.datas,params.updateSpan);
	  	this.initSliderEvent(params.slider_array,scope.datas);
	  	this.initChart(true);
	}
	
	this.updataInputAfter = function(id,value,datas){
		if(id == "kgcsjrzc"||id == "gdzc"||id == "wxzc"){
			setJrzc(true);
		} 
		if(id == "cqjk"||id == "sszb"||id == "wfplr"){
			setJgxfz(true);
		}
		if(id == "yszk" || id == "qtysk" || id == "ch"){
			setJyxzc(true);
		}
		if(id == "yfzk" || id == "yfzgxc"||id == "qtyfk"){
			setJyxfz(true);
		}
	}
    this.setFormula = function(action){
    	setJrzc(action);
    	setJgxfz(action);
    	setJyxzc(action);
    	setJyxfz(action);
    }
    /*结构性资产：可供出售金融资产+持有至到期投资+长期应收款+长期股权投资+投资性房地产+固定资产+在建工程+工程物资+固定资产清理+
     * 生产性生物资产+油气资产+无形资产+开发支出+商誉+长期待摊费用+递延所得税资产+其他非流动资产（资产负债表期末数）
     * kgcsjrzc+cyzdqtz+cyzdqtz+cqysk+cqgqtz+tzxfdc+gdzc+zjgc+gcwz+gdzcql+
     * 		scxswzc+yqzc+wxzc+kfzc+sy+cqdtfy+dysdszc+qtfldzc
     * 
     * 营运资本：结构性负债-结构性资产
     * */
    function setJrzc(action){
    	
		scope.datas["jgxzc"] = Utils.formatFloat(scope.datas.kgcsjrzc+scope.datas.cyzdqtz+scope.datas.cyzdqtz+
				scope.datas.cqysk+scope.datas.cqgqtz+scope.datas.tzxfdc+scope.datas.gdzc+scope.datas.zjgc+
				scope.datas.gcwz+scope.datas.gdzcql+scope.datas.scxswzc+scope.datas.yqzc+scope.datas.wxzc+
				scope.datas.kfzc+scope.datas.sy+scope.datas.cqdtfy+scope.datas.dysdszc+scope.datas.qtfldzc,2);
		
		scope.datas["yyzb"] = Utils.formatFloat(scope.datas["jgxzc"] - scope.datas["jgxfz"],2);
		setYyzbHTML();
		if(action)scope.updataSpanAndProgess("jgxzc_span");
		if(action)scope.updataSpanAndProgess("yyzb_span");
    }
	
    /*
     * 结构性负债：实收资本+资本公积-减：库存股+盈余公积+未分配利润+*少数股东权益+长期借款+应付债券+长期应付款+专项应付款+
     * 			预计负债+递延所得税负债+其他非流动负债（资产负债表期末数）
     * sszb+zbgj+jkcg+yygj+wfplr+(ssgdqy)+cqjk+yfzq+cqyfk+zxyfk+yjfz+dysdsfz+qtfldzc
     * */
    function setJgxfz(action){
		 scope.datas["jgxfz"] = Utils.formatFloat(scope.datas.sszb+scope.datas.zbgj+scope.datas.jkcg+scope.datas.yygj+
		 			scope.datas.wfplr+scope.datas.ssgdqy+scope.datas.cqjk+scope.datas.yfzq+scope.datas.cqyfk+scope.datas.zxyfk+
		 			scope.datas.yjfz+scope.datas.dysdsfz+scope.datas.qtfldzc,2);
		 scope.datas["yyzb"] = Utils.formatFloat(scope.datas["jgxzc"] - scope.datas["jgxfz"],2);
		 setYyzbHTML();
		 if(action)scope.updataSpanAndProgess("jgxfz_span");
		 if(action)scope.updataSpanAndProgess("yyzb_span");
    }
    /*
     * 营运资本文字：=IF(营运资本>0,"投融资活动是协调的","投融资活动存在资金缺口，并需要占用流动资金为："&ROUND(ABS(营运资本),2))
     * */
    function setYyzbHTML(){
    	if(scope.datas["yyzb"] > 0){
    		$("#h1").html("经营活动是协调的，可以放心");
    		$("#h1").css({'color':'green'});
    	}else{
    		$("#h1").css({'color':'red'});
    		$("#h1").html("投融资活动存在资金缺口，并需要占用流动资金为："+Math.round(Math.abs(scope.datas["yyzb"]),2));
    	}
    }
    /*
     * 经营性资产：应收账款+ 预付款项+应收利息+ 应收股利+其他应收款+存货+一年内到期的非流动资产+其他流动资产
     * 			yszk+(yfkx+yslx+ysgl)+qtysk+ch+ynn+qtldzc
     * 营运资金需求：经营性资产-经营性负债
     * */
    function setJyxzc(action){
    	scope.datas["jyxzc"] = Utils.formatFloat(scope.datas.yszk+scope.datas.yfkx+scope.datas.yslx+
    				scope.datas.ysgl+scope.datas.qtysk+scope.datas.ch+scope.datas.ynn+scope.datas.qtldzc,2);
   		scope.datas["yyzjxq"] = Utils.formatFloat(scope.datas["jyxzc"] - scope.datas["jyxfz"],2);
   		setYyzjxqHTML();
   		if(action)scope.updataSpanAndProgess("jyxzc_span");
   		if(action)scope.updataSpanAndProgess("yyzjxq_span");
    }
    /*
     * 经营性负债：应付账款+预收款项+应付职工薪酬+应交税费+ 应付利息+ 应付股利+其他应付款+一年内到期的非流动负债+其他流动负债（资产负债表期末数）
     * 		yfzk+yskx+yfzgxc+yjsf+yflx+yfgl+qtyfk+ynnn+qtldfz
     * */
    function setJyxfz(action){
    	scope.datas["jyxfz"] = Utils.formatFloat(scope.datas.yfzk+scope.datas.yskx+scope.datas.yfzgxc+
    			scope.datas.yjsf+scope.datas.yflx+scope.datas.yfgl+scope.datas.qtyfk+
    			scope.datas.ynnn+scope.datas.qtldfz,2);
    	scope.datas["yyzjxq"] = Utils.formatFloat(scope.datas["jyxzc"] - scope.datas["jyxfz"],2);
    	setYyzjxqHTML();
   		if(action)scope.updataSpanAndProgess("jyxfz_span");
   		if(action)scope.updataSpanAndProgess("yyzjxq_span");
    }
    /*
     * 营运资金需求文字：=IF(营运资金需求<0,"经营活动是协调的","经营活动存在资金缺口为:"&ROUND(营运资金需求,2))
     * */
    function setYyzjxqHTML(){
    	if(scope.datas["yyzjxq"] < 0){
    		$("#h2").html("经营活动是协调的");
    		$("#h2").css({"color":"green"});
    	}else{
    		$("#h2").html("经营活动存在资金缺口为:"+Math.round(scope.datas["yyzjxq"],2));
    		$("#h2").css({"color":"red"});
    	}
    }
    /*
     * 现金支付能力=（货币资金+交易性金融资产+应收票据）-（短期借款+应付票据）
     * 		(hbzj+jyxjrzc+yspj)-(dqjk+yfpj)
     * 现金支付能力文字：
     * IF( AND(现金支付能力>0, 营运资金需求>0, 营运资本>0, 营运资本>营运资金需求),"协调且有支付能力",
     * IF(AND(现金支付能力>0,营运资金需求<0, 营运资本>0),"资金大量富裕",
     * IF(AND(现金支付能力>0,营运资金需求<0, 营运资本<0, ABS(营运资本)<ABS(营运资金需求)),"不协调但能够维持",
     * IF(AND(现金支付能力<0, 营运资金需求<0, 营运资本<0,ABS(营运资本)>ABS(营运资金需求)),"不协调",
     * IF(AND(现金支付能力<0,营运资金需求>0,营运资本>0,营运资本<营运资金需求),"协调但有支付困难","严重不协调"))
     * */
    function SetXjzfnl(){
    	scope.datas["xjzfnl"] = Utils.formatFloat((scope.datas.hbzj+scope.datas.jyxjrzc+scope.datas.yspj)-
    			(scope.datas.dqjk+scope.datas.yfpj),2);
    	setXjzfnlHTML();
    	//console.dir(scope.datas["xjzfnl"]);
    	return scope.datas["xjzfnl"];
    }
    /*
     * 现金支付能力文字
     * */
    function setXjzfnlHTML(){
    	if((scope.datas["xjzfnl"] > 0)&&(scope.datas["yyzjxq"] > 0)&&(scope.datas["yyzb"] > 0)&&(scope.datas["yyzb"] > scope.datas["yyzjxq"])){
    		console.dir("1");
    		$("#h4").html("协调且有支付能力");
    	}else if((scope.datas["xjzfnl"] > 0)&&(scope.datas["yyzjxq"] < 0)&&(scope.datas["yyzb"] > 0)){
    		console.dir("2");
    		$("#h4").html("资金大量富裕");
    	}else if((scope.datas["xjzfnl"] > 0)&&(scope.datas["yyzjxq"] < 0)&&(scope.datas["yyzb"] < 0)&&(Math.abs(scope.datas["yyzb"])<Math.abs(scope.datas["yyzjxq"]))){
    		console.dir("3");
    		$("#h4").html("不协调但能够维持");
    	}else if((scope.datas["xjzfnl"] < 0)&&(scope.datas["yyzjxq"] < 0)&&(scope.datas["yyzb"] < 0)&&(Math.abs(scope.datas["yyzb"])>Math.abs(scope.datas["yyzjxq"]))){
    		console.dir("4");
    		$("#h4").html("不协调");
    	}else if((scope.datas["xjzfnl"] < 0)&&(scope.datas["yyzjxq"] > 0)&&(scope.datas["yyzb"] > 0)&&(scope.datas["yyzb"] < scope.datas["yyzjxq"])){
    		console.dir("5");
    		$("#h4").html("严重不协调");
    	}
    }
    
	function getAngularGaugeObj(){
      return {
      			chartType:0,//图表类型 ：0为单值数据图表;1为多单数据图表;2为多系数据图表
	            swfName:"AngularGauge",
	            domId:domArray[0],//渲染的dom节点
	            attributes:' manageResize="1" origW="415" origH="415"  ' +
	            		'manageValueOverlapping="1" showValue="1" autoAlignTickValues="1"  ' +
	            		'   tickValueDistance="1" bgColor="FFFFFF" upperLimit="5000" lowerLimit="0" ' +
	            		'numberSuffix="" baseFontColor="000000"  majorTMNumber="11" majorTMColor="000000" ' +
	            		' majorTMHeight="30" minorTMNumber="5" minorTMColor="000000" minorTMHeight="15" ' +
	            		'showGaugeBorder="0" gaugeOuterRadius="170" gaugeInnerRadius="140" gaugeOriginX="210"' +
	            		' gaugeOriginY="210" gaugeAlpha="50" placeValuesInside="1" toolTipBgColor="FFFFFF" ' +
	            		'toolTipBorderColor="CCCCCC" gaugeFillMix="" showShadow="0" annRenderDelay="0"' +
	            		' pivotRadius="18" pivotFillMix="{E6E6E6},{999999}" pivotBorderColor="bebcb0"' +
	            		' pivotFillRatio="70,30" showTickValues="0" showBorder="0" gaugeStartAngle="230" ' +
	            		'gaugeEndAngle="-50" ',
	            		
	           	color : ["FF0000","ffff00","00ff00"],
				colorRange:["0","3000","4000","5000"],
				datas : SetXjzfnl(),
				dialsAttr:' bgColor="000000,4D4D4D" borderAlpha="0" baseWidth="20" topWidth="1" rearExtension="50" valueY="333" radius="150"',
	          	styles:'<definition><style type="font" name="a" bgColor="FF0000" size="20" borderColor="FF0000"' +
	          			'  baseFontColor="FF0000" /><style name="MyFirstBevel" type="Bevel" /></definition>' +
	          			'<application><apply toObject="Value" styles="a"/><apply toObject="Value" ' +
	          			'styles="MyFirstBevel"/></application> ',
	          	annotations:'<annotationGroup x="210" y="210" showBelow="1"><annotation type="circle" x="0" y="0" radius="200"' +
	          			' fillColor="35BADC,35BDDF, C5F4FF"  fillRatio="80,15, 5" borderColor="35BADC" />' +
	          			'<annotation type="circle" x="0" y="0" radius="190" fillColor="FFFFFF, FFFFFF" ' +
	          			'fillRatio="20,80" borderColor="FFFFFF" /><annotation type="circle" x="0" y="0" ' +
	          			'radius="190"  fillColor="E6E6E6, FFFFFF" fillAlpha="50" borderColor="E6E6E6" />' +
	          			'</annotationGroup>',
				width:"80%",
	          	height:"23.3%"
	         };
	}
	function getPieChartObj(){
			return {
				 chartType:1,//图表类型 ：0为单值数据图表;1为多单数据图表;2为多系数据图表
			     swfName:"Pie2d",//这个就不用说了吧！  
			     domId:domArray[1],//渲染的dom节点
			     datas:[{index0:"",index1:"",index2:""},[
			     		{index0:"1",index1:"可供出售金融资产",index2:scope.datas.kgcsjrzc},
			        	{index0:"2",index1:"固定资产",index2:scope.datas.gdzc},
			        	{index0:"3",index1:"无形资产",index2:scope.datas.wxzc},
			        	{index0:"4",index1:"持有至到期投资",index2:scope.datas.cyzdqtz},
			        	{index0:"5",index1:"长期应收款",index2:scope.datas.cqysk},
			        	{index0:"6",index1:"长期股权投资",index2:scope.datas.cqgqtz},
			        	{index0:"7",index1:"投资性房地产",index2:scope.datas.tzxfdc},
			        	{index0:"8",index1:"在建工程",index2:scope.datas.zjgc},
			        	{index0:"9",index1:"工程物资",index2:scope.datas.gcwz},
			        	{index0:"10",index1:"固定资产清理",index2:scope.datas.gdzcql},
			        	{index0:"11",index1:"生产性生物资产",index2:scope.datas.scxswzc},
			        	{index0:"12",index1:"油气资产",index2:scope.datas.yqzc},
			        	{index0:"13",index1:"开发支出",index2:scope.datas.kfzc},
			        	{index0:"14",index1:"商誉",index2:scope.datas.sy},
			        	{index0:"15",index1:"长期待摊费用",index2:scope.datas.cqdtfy},
			        	{index0:"16",index1:"递延所得税资产",index2:scope.datas.dysdszc},
			        	{index0:"17",index1:"其他非流动资产",index2:scope.datas.qtfldzc}
			        ]],
			     attributes:'manageResize="1"  showLabels="0" chartLeftMargin="0" ' +
			     			' legendIconScale="0.8" legendAllowDrag="0" minimiseWrappingInLegend="0" ' +
			     			'showBorder="0" legendPosition="RIGHT" chartTopMargin="0"  bgColor="ffffff" ' +
			     			'bgAlpha="0,0"  showValues="0" isSmartLineSlanted="1"  showLegend="0"',
			     color:["1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900","6B8E23","9400D3","FF0000",
			       			 "1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900"],
			     width:"90%",
			     height:250,
			     event:{
			     	type:1,
			     	name:"showPie"
			     }
			};
		}

	function getPieChartObj2(){
			return {
				 chartType:1,//图表类型 ：0为单值数据图表;1为多单数据图表;2为多系数据图表
			     swfName:"Pie2d",//这个就不用说了吧！  //AngularGauge.swf
			     domId:domArray[2],//渲染的dom节点
			     datas:[{index0:"",index1:"",index2:""},[
			     		{index0:"1",index1:"实收资本",index2:scope.datas.sszb},
			        	{index0:"2",index1:"资本公积",index2:scope.datas.zbgj},
			        	{index0:"3",index1:"减：库存股",index2:scope.datas.jkcg},
			        	{index0:"4",index1:"盈余公积",index2:scope.datas.yygj},
			        	{index0:"5",index1:"未分配利润",index2:scope.datas.wfplr},
			        	{index0:"6",index1:"少数股东权益",index2:scope.datas.ssgdqy},
			        	{index0:"7",index1:"长期借款",index2:scope.datas.cqjk},
			        	{index0:"8",index1:"应付债券",index2:scope.datas.yfzq},
			        	{index0:"9",index1:"长期应付款",index2:scope.datas.cqyfk},
			        	{index0:"10",index1:"专项应付款",index2:scope.datas.zxyfk},
			        	{index0:"11",index1:"预计负债",index2:scope.datas.yjfz},
			        	{index0:"12",index1:"递延所得税负债",index2:scope.datas.dysdsfz},
			        	{index0:"13",index1:"其他非流动负债",index2:scope.datas.qtfldfz}
			        ]],
			     attributes:' manageResize="1"  showLabels="0" chartLeftMargin="0" ' +
			     			' legendIconScale="0.8" legendAllowDrag="0" minimiseWrappingInLegend="0" ' +
			     			'showBorder="0" legendPosition="RIGHT" chartTopMargin="0"  bgColor="ffffff" ' +
			     			'bgAlpha="0,0"  showValues="0" isSmartLineSlanted="1"  showLegend="0"',
			     color:["1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900","6B8E23","9400D3","FF0000",
			       			 "1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900"],
			     width:"90%",
			     height:250,
			     event:{
			     	type:1,
			     	name:"showPie"
			     }
			};
		}
	
	function getPieChartObj3(){
			return {
				 chartType:1,//图表类型 ：0为单值数据图表;1为多单数据图表;2为多系数据图表
			     swfName:"Pie2d",//这个就不用说了吧！  //AngularGauge.swf
			     domId:domArray[3],//渲染的dom节点
			     datas:[{index0:"1",index0:"",index1:"",index1:""},[
			     		{index0:"2",index1:"应收账款",index2:scope.datas.yszk},
			        	{index0:"3",index1:"预付款项",index2:scope.datas.yfkx},
			        	{index0:"4",index1:"应收利息",index2:scope.datas.yslx},
			        	{index0:"5",index1:"应收股利",index2:scope.datas.ysgl},
			        	{index0:"6",index1:"其他应收款",index2:scope.datas.qtysk},
			        	{index0:"7",index1:"存货",index2:scope.datas.ch},
			        	{index0:"8",index1:"一年内到期的非流动资产",index2:scope.datas.ynn},
			        	{index0:"9",index1:"其他流动资产",index2:scope.datas.qtldzc}
			        ]],
			     attributes:' manageResize="1"  showLabels="0" chartLeftMargin="0" ' +
			     			' legendIconScale="0.8" legendAllowDrag="0" minimiseWrappingInLegend="0" ' +
			     			'showBorder="0" legendPosition="RIGHT" chartTopMargin="0"  bgColor="ffffff" ' +
			     			'bgAlpha="0,0"  showValues="0" isSmartLineSlanted="1"  showLegend="0"',
			     color:["1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900","6B8E23","9400D3","FF0000",
			       			 "1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900"],
			     width:"90%",
			     height:250,
			      event:{
			     	type:1,
			     	name:"showPie"
			     }
			};
		}
	
	function getPieChartObj4(){
			return {
				 chartType:1,//图表类型 ：0为单值数据图表;1为多单数据图表;2为多系数据图表
			     swfName:"Pie2d",//这个就不用说了吧！  //Pie2D.swf
			     domId:domArray[4],//渲染的dom节点
			     datas:[{index0:"",index1:"",index2:""},[
			     		{index0:"1",index1:"应付账款",index2:scope.datas.yszk},
			        	{index0:"2",index1:"预付款项",index2:scope.datas.yfkx},
			        	{index0:"3",index1:"应付职工薪酬",index2:scope.datas.yfzgxc},
			        	{index0:"4",index1:"应交税费",index2:scope.datas.yjsf},
			        	{index0:"5",index1:"应付利息",index2:scope.datas.yflx},
			        	{index0:"6",index1:"应付股利",index2:scope.datas.yfgl},
			        	{index0:"7",index1:"其他应付款",index2:scope.datas.qtyfk},
			        	{index0:"8",index1:"一年内到期的非流动负债",index2:scope.datas.ynnn},
			        	{index0:"9",index1:"其他流动负债",index2:scope.datas.qtldfz}
			        ]],
			     attributes:'manageResize="1"  showLabels="0" chartLeftMargin="0" ' +
			     			' legendIconScale="0.8" legendAllowDrag="0" minimiseWrappingInLegend="0" ' +
			     			'showBorder="0" legendPosition="RIGHT" chartTopMargin="0"  bgColor="ffffff" ' +
			     			'bgAlpha="0,0"  showValues="0" isSmartLineSlanted="1"  showLegend="0"',
			     color:["1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900","6B8E23","9400D3","FF0000",
			       			 "1C86EE","EEC900","6B8E23","9400D3","FF0000","1C86EE","EEC900"],
			     width:"90%",
			     height:250,
			      event:{
			     	type:1,
			     	name:"showPie"
			     }
			};
		}
		
	this.initChart = function(action,id){
		if(action)new Cnbi.model.Chart(getAngularGaugeObj());	
    	if(id == "kgcsjrzc"||id == "gdzc"||id == "wxzc"){
    		new Cnbi.model.Chart(getPieChartObj());
    	}else if(id == "cqjk"||id == "sszb"||id == "wfplr"){
    		new Cnbi.model.Chart(getPieChartObj2());
    	}else if(id == "yszk" || id == "qtysk" || id == "ch"){
    		new Cnbi.model.Chart(getPieChartObj3());
    	}else if(id == "yfzk" || id == "yfzgxc"||id == "qtyfk"){
    		new Cnbi.model.Chart(getPieChartObj4());
    	}else{
    		new Cnbi.model.Chart(getPieChartObj());
    		new Cnbi.model.Chart(getPieChartObj2());
    		new Cnbi.model.Chart(getPieChartObj3());
    		new Cnbi.model.Chart(getPieChartObj4());
    	}
     }
    scope.init();
}

window.showPie = function(String){
	
	var chartId = String.split("|")[2],
		label = String.split("|")[3],
		value = String.split("|")[4];
	var id = chartId.split("_")[0];
	var title;
	if(id=="pie1"){
		title = $(".title1").text();
	}else if(id=="pie2"){
		title = $(".title2").text();
	}else if(id=="pie3"){
		title = $(".title3").text();
	}else if(id=="pie4"){
		title = $(".title4").text();
	}
		
	
	var  left = (screen.width-600)/2;//width
    var  top = (screen.height-470)/2;//height Utils.getBasePathUrl()+'forward.cnbi
	window.open('pie1.jsp?label='+label+'&vaule='+value+'&forward=101'+'&title='+encodeURI(encodeURI(title)),"pie","width=600,height=460,top="+top+", left="+left+",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no"); 
}

